<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/mui.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/general.css"/>
		<style type="text/css">
			.pherder{
				width: 100%;
				display: flex;
				justify-content: flex-start;
				align-content: center;
				background-color: white;
				padding: 0.8em;
				margin-bottom: 0.4em;
			}
			.pimg{
				width: 20%;
				padding: 0.6em;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			.pimg>img{
				width: 60px;
				border-radius:50%;
			}
			.pcontent{
				width: 60%;
				display: flex;
				justify-content: center;
				align-items: flex-start;
				flex-direction: column;
			}
			.div8{
				width: 100%;
				display: flex;
				justify-content: flex-start;
				align-items: flex-start;
				flex-wrap: wrap;
			}
			.div8>div{
				width: 25%;
				padding: 2%;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				background-color: white;
			}
			.div8>div>div{
				white-space: nowrap;
			}
			.xgd{
				width: 100%;
				height: 5px;
				background-color: #EBF4FF;
			}
			.mainimg{
				width: 30px;
				height: 30px;
				margin: 0.4em;
			}
			.mainimg>img{
				width: 100%;
				height: 100%;
			}
			*{
				font-family: "微软雅黑";
				color: #2f2f2f;
				font-size: 0.9em;
			}
			.sdiv{
				display: flex;
				justify-content: flex-start;
				align-items: center;
				padding: 0.2em 1em;
			}
			a>img{
				width: 100%;
				max-height: 212px;
			}
			.mbe4{
				margin: 0.4em 0;
			}
			.ctext{
				position: absolute;
				top: 50%;
				right: 40px;
			    -webkit-transform: translateY(-50%);
			    transform: translateY(-50%);
			    padding: 0.3em;
			}
			.ctext2{
				position: absolute;
				top: 50%;
				right: 10px;
			    -webkit-transform: translateY(-50%);
			    transform: translateY(-50%);
			    padding: 0.3em;
			    z-index: 1;
			    background-color: white;
			}
			.hicon>img {
			    width: 2.5em;
			    height: 2.5em;
			}
			.hicon{
				z-index: 9999 !important;
			}
			h1{
				width: 50% !important;
				margin: 0 auto !important;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">会员详情</h1>
		    <div class="hicon mui-icon-right-nav mui-pull-right" id="deldiv">
		    	<img src="img/del-white.png"/>
		    </div>
		    <div class="hicon mui-icon-right-nav mui-pull-right" id="bjdiv">
		    	<img src="img/bj-white.png"/>
		    </div>
		</header>
		<div class="mui-content">
		    <div class="pherder" id="pherderid">
		    	<div class="pimg">
		    		<img src="../../img/member-header.png"/>
		    	</div>
		    	<div class="pcontent">
		    		<div class="pname">
		    			
		    		</div>
		    		<div class="pmess fe08">
		    			联系方式：
		    		</div>
		    		<div class="ptime fe08">
		    			消费日期：
		    		</div>
		    	</div>
		    </div>
		    
		    <div class="div8">
				<div class="" id="telephone"><div class="mainimg">
		    	<img src="img/phone-blue.png"/>
		    	</div><div id="">打电话</div></div>
		    	
		    	<div class="" onclick="gopage('fastCharge')"><div class="mainimg">
		    	<img src="img/chongz-blue.png"/>
		    	</div><div id="">会员充值</div></div>
		    	
		    	<div class="" onclick="gopage('memberInformation')"><div class="mainimg">
		    	<img src="img/cika-blue.png"/>
		    	</div><div id="">次卡扣减</div></div>
		    	
		    	<div class="" onclick="gocashier()"><div class="mainimg">
		    	<img src="img/syjz-blue.png"/>
		    	</div><div id="">收银记账</div></div>
		    	
			</div>
		    
		    <div class="mbe4">
		    	<ul class="mui-table-view" id="dataid">
		            <li class="mui-table-view-cell" >
		                <a class="mui-navigate-right">
		                    会员余额
		                </a>
		                <span class="ctext2 fe09">
		                	
		                </span>
		            </li>
		            <li class="mui-table-view-cell" onclick="gopage2('integral')">
		                <a class="mui-navigate-right">
		                     积分
		                </a>
		                 <span class="ctext fe09">
		                	
		                </span>
		            </li>
		            <li class="mui-table-view-cell" onclick="gopage('vouchers')">
		                <a class="mui-navigate-right">
		                     优惠券
		                </a>
		                 <span class="ctext fe09">
		                	
		                </span>
		            </li>
		           
		            <li class="mui-table-view-cell" onclick="gopage2('follow-up-records')">
		                <a class="mui-navigate-right">
		                     跟进记录
		                </a>
		                 <span class="ctext fe09">
		                	
		                </span>
		            </li>
		            	 <!--
	                    	作者：592176224@qq.com
	                    	时间：2019-03-18
	                    	描述：
	                 
				             <li class="mui-table-view-cell" >
				                <a class="mui-navigate-right">
				                     累计消费
				                </a>
				                 <span class="ctext2 fe09">
				                	
				                </span>
				            </li>
		               -->
		             <li class="mui-table-view-cell">
		                <a class="mui-navigate-right" onclick="gopage2('records-of-consumption')">
		                     历史消费
		                </a>
		                 <span class="ctext fe09">
		                	
		                </span>
		            </li>
		             <li class="mui-table-view-cell">
		                <a class="mui-navigate-right">
		                     推荐人
		                </a>
		                 <span class="ctext fe09">
		                	
		                </span>
		            </li>
		            <li class="mui-table-view-cell">
		                <a class="mui-navigate-right">
		                     联系电话
		                </a>
		                 <span class="ctext2 fe09">
		                	
		                </span>
		            </li>
		            <li class="mui-table-view-cell">
		                <a class="mui-navigate-right">
		                     所属门店
		                </a>
		                 <span class="ctext2 fe09">
		                	
		                </span>
		            </li>
		        </ul>
		    </div>
		</div>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var mid = 0,phone = 0;
			window.onload = function(){
				mid = getrequest().mid||146;
				console.log(mid);
				$('#deldiv').on('tap',function(e) {
					
					mui.confirm("是否删除该会员","",["取消","确认"],function(e){
						if(e.index == 1){
							console.log("删除");
							var data = {
								url:"/api/member/sdel",
								data:{
									access_token:acctoken(),
									id:mid,
								}
							}
							
							ajax(data,function(res){
								console.log(res)
								mui.toast(res.msg);
								ws=plus.webview.currentWebview();
								wo=ws.opener();
								wo.evalJS("refresh();");
								mui.back();
							})
						}
					})
					
           	 	});
           	 	
           	 	$('#bjdiv').on('tap',function(e) {
           	 		console.log("编辑")
           	 		mui.openWindow({
                        url: 'modify-the-member.html?mid='+mid,
                        id: 'modify-the-member',
                        //extras: list,
                	});
           	 	});
           	 	getmemberdetail();
           	 	document.getElementById("telephone").addEventListener('tap',function(){
		            var btnArray=['拨打','取消'];
		            mui.confirm('是否拨打'+phone+'?','提示',btnArray,function(e){
		                if(e.index == 0){
		                    plus.device.dial(phone,false);
		                }
		            });
		        });
			}
			
			function onshow(){
				console.log("刷新");
				getmemberdetail();
			}
			
			
			function getmemberdetail(){
				var data = {
					url:"/api/member/detail",
					data:{access_token:acctoken(),id:mid}
				}
				ajax(data,function(res){
					console.log("会员详情",res);
					if(res.data != null){
						phone = res.data.phone;
						setpherder(res.data);
						setdatalist(res.data);
					}else{
						back_toast("暂无权限查看");
					}
				})
			}
			function setdatalist(data){
				var str = '<li class="mui-table-view-cell" >'+
						'<a class="mui-navigate-right">会员余额</a><span class="ctext2 fe09">'+
		                data.stay_money+
		                '元</span></li>'+
		                '<li class="mui-table-view-cell" onclick="gopage2(\'integral\')">'+
		                '<a class="mui-navigate-right">积分</a><span class="ctext fe09">'+
		                data.stay_score+
		                '</span></li>'+
		                '<li class="mui-table-view-cell" onclick="gopage2(\'coupons-list\')">'+
		                '<a class="mui-navigate-right">优惠券</a><span class="mui-badge mui-badge-danger">';
		                if(data.member_coupon && data.member_coupon.length > 0){
		                	str += data.member_coupon.length+'张';
		                }else{
		                	str += '0张';
		                }
		                str += '</span>'+
		                '</li>'+
		                '<li class="mui-table-view-cell" onclick="gopage2(\'follow-up-records\')">'+
		                '<a class="mui-navigate-right">跟进记录</a><span class="ctext fe09">'+
		                '</span></li>'+
		                /*
		                '<li class="mui-table-view-cell" >'+
		               '<a class="mui-navigate-right">累计消费</a><span class="ctext2 fe09">'+
		                	data.total_pay+
		                	'元</span></li>'+*/
		             '<li class="mui-table-view-cell">'+
		                '<a class="mui-navigate-right" onclick="gopage2(\'records-of-consumption\')"> 历史消费'+
		                '</a><span class="ctext fe09">'+
		                	data.total_pay+
		               '</span></li>'+
		             	'<li class="mui-table-view-cell">'+
		                '<a class="mui-navigate-right">推荐人</a><span class="ctext fe09">';
		                if(data.recommend_id > 0){
		                	str += data.recommend_username;
		                }
		                str += '</span></li>'+
		             	'<li class="mui-table-view-cell">'+
		                '<a class="mui-navigate-right">联系电话</a><span class="ctext2 fe09">'+
		                data.phone+
		               '</span></li>'+
		               '<li class="mui-table-view-cell">'+
		                '<a class="mui-navigate-right">所属门店</a><span class="ctext2 fe09">'+
		                data.store_name+
		               '</span></li>';
				g("dataid").innerHTML = str;
			}
			function setpherder(data){
				var str = '<div class="pimg">';
					if(data.images&&data.images.path_name){
						str += '<img src="'+data.images.path_name+'"/>'
					}else{
						str += '<img src="../../img/member-header.png"/>';
					}
		    		str += '</div><div class="pcontent"><div class="pname">'+
		    		data.username+
		    		'</div><div class="pmess fe08">联系方式：'+
		    		data.phone+
		    		'</div><div class="ptime fe08">消费日期：'+
		    		data.editor_time+
		    		'</div></div></div>';
				
				g("pherderid").innerHTML = str;
			}
			function gopage(url){
				console.log(mid);
				var list = {mid:mid}
				mui.openWindow({
				    url: '../'+url+'.html?mid='+mid, 
				    id: url,
				    extras: list,
				});
			}
			function gocashier(){
				console.log(mid);
				var list = {mid:mid}
				mui.openWindow({
				    url: '../cashier.html?mid='+mid, 
				    id: 'cashier',
				    extras: list,
				});
			}
			function gopage2(url){
				console.log(mid);
				var list = {mid:mid}
				mui.openWindow({
				    url: url+'.html?mid='+mid,
				    id: url,
				    extras: list,
				});
			}
			
		</script>
	</body>

</html>